package com.yaoxuguang.concurrence.synchronizedpackage.variableFromInstance;

/**
 * @author yaoxuguang
 * @Title: yao-interview
 * @Package com.yaoxuguang.concurrence.synchronizedpackage.methodInnerVariable
 * @Description: 实例变量存在非线程安全的问题
 * @date 2018年12月18日9:54
 */
public class HasSelfPraviteNum {
    private int num = 0;
//    synchronized public void add(String username){  线程安全
   public void add(String username){
        if("a".equals(username.trim())){
            num = 100;
            System.out.println("a set over...");
        }else{
            num = 200;
            System.out.println("b set over...");
        }
        System.out.println(username +"num="+num);
    }
}
